
#ifndef INPUTWATCHER_H_
#define INPUTWATCHER_H_

#include <rodos.h>
#include "Gui.h"

#include "worker-monitor-topics.h"
#include "SatelliteInterface.h"
#include <sstream>



/**
 * Class InputWatcher
 * A threadbased class checking and handling the userinput multiple times per second.
 */

class InputWatcher : public Thread {
private:
	//Maximum size of input, exceeding will reset the input
	static const int INPUTSIZE;

	//Pointer to our Maingui to set Replies.
	static Gui *singleton;

	//Holds the input
	char* input;

	//Counts the inputlength
	int i;

	//Interprets and executes the userinput, or reports an invalid input
	void handleInput();

	//constant line where the input is written/type
	static const int lineInput;

public:
	//Constructor
	InputWatcher();

	virtual ~InputWatcher();

	//inherited from Thread, used to set the global parameters
	void init();

	//inherited from Thread, periodically checks the consoleinput and calls the handleInput() function
	//if the input is complete (by entering Enter) or to big to be handled.
	void run();

	/**Returs a combined string of a textmessage and an int,
	 * which is needed to create some replies
	 *	@param msg - the message that needs a number to be added
	 *	@param num - the numerical int type to be added
	 *	@returns a String holding the msg with the converted num at the end
	 */
	string intToStr(const char* msg, int num);

};
static InputWatcher watcher;

#endif /* INPUTWATCHER_H_ */
